nmc: P1 PC embedded template builder (re-homed btc mirror) + KATs - #213
Merged
Conversation
Adds nmc::coin::Mempool — a byte-faithful mirror of src/impl/btc/coin/ mempool.hpp re-homed into namespace nmc::coin so the NMC coin tree stays self-contained (no btc::coin symbols). Namecoin is a Bitcoin fork: same wire format, 21M money cap, 100-block coinbase maturity (NMC_LIMITS, instantiated locally from the public core::coin::ChainLimits; no core edit). Feeds the P1 PC template builder next. Coverage: +3 KATs in the existing (CI-allowlisted) nmc_auxpow_merkle_test (add/contains/remove + dedup, feerate-ordered selection, confirmed-block cleanup). Suite 66 -> 69 green. Fence held: src/impl/nmc/ only, no build.yml / src/core / bitcoin_family change. Reference: namecoin-core (Bitcoin fork) txmempool.cpp / amount.h MAX_MONEY, consensus.h COINBASE_MATURITY.
Re-home the BTC native block-template builder into the NMC coin tree so the
embedded merge-mined Namecoin chain can build block templates (WorkData)
natively from its HeaderChain + Mempool, without the getblocktemplate RPC.
* coin/rpc_data.hpp -- nmc::coin::rpc::WorkData (template payload)
* coin/template_builder.hpp -- get_block_subsidy (50 NMC, halving every
210,000 blocks, identical to Bitcoin), compute_merkle_root (SHA256d),
CoinNodeInterface, TemplateBuilder::build_template, EmbeddedCoinNode;
log tags [EMB-NMC].
* coin/header_chain.hpp -- add get_header_by_height (parent-link walk,
no height index), is_synced (DEFAULT_MAX_TIP_AGE gate), and the
get_next_work_required / calculate_next_work_required retarget the
builder needs. NMC shares Bitcoins 2016-block / 10-minute retarget.
* coin/coin_smoke.cpp + CMakeLists -- force-compile the header-only builder.
PC is the STRUCTURAL builder only; merge-mining commitment / dual-target
(phase PD) are not implemented here.
KATs: nmc_template_builder_test (10) covers subsidy halving boundaries,
compute_merkle_root (0/1/2/odd/even leaves, independently re-derived), and
build_template on a seeded chain (tip -> WorkData; empty -> nullopt).
Suite 69 -> 79 green. Fenced to src/impl/nmc/ (plus the one build.yml
--target allowlist line). btc/core trees consumed READ-ONLY.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NMC P1 PC — embedded template builder
Re-homes
src/impl/btc/coin/template_builder.hppintonamespace nmc::coin. Builds block templates natively from a validated HeaderChain + Mempool, removing the getblocktemplate RPC dependency for the embedded merge-mined Namecoin chain.Provides (header-only):
get_block_subsidy()(NMC inherits Bitcoin halving: 50 NMC, 210k interval), SHA256dcompute_merkle_root(),TemplateBuilder::build_template() -> WorkData,CoinNodeInterface+EmbeddedCoinNode(HeaderChain + Mempool backed).Scope: STRUCTURAL builder only. Merge-mining specifics (aux commitment in parent coinbase, dual-target submission) are PD, NOT here.
Tests: new
nmc_template_builder_test— 10 KATs (5 merkle + 3 build + 2 sync-state), all GREEN, build + run exit 0 locally.Fence:
src/impl/nmc/only; btc tree consumed READ-ONLY. One additive shared-file edit:.github/workflows/build.ymladdsnmc_template_builder_testto the two CI test-run lists (matches DGB lane convention; required so the consensus-bearing builder actually runs in CI given #137 NOT_BUILT history).Stacked on #210 (nmc/p1-pb-mempool). Base is the PB branch; will retarget to master once #210 lands.
I do not self-merge — operator merge card via integrator.